﻿using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sync_signal_light.subs
{
    public partial class FrmLogs : Sunny.UI.UIForm
    {
        public FrmLogs()
        {
            InitializeComponent();
        }

        private void FrmLogs_Load(object sender, EventArgs e)
        {
            try
            {
                this.Text = "通讯日志查看 - " + Application.ProductVersion;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private bool START = true;
        private void btn_event_click(object sender, EventArgs e)
        {
            UISymbolButton btn = sender as UISymbolButton;
            switch (btn.Name.ToLower())
            {
                case "btn_start":
                    {
                        START = !START;
                        if (START)
                        {
                            btn_start.Text = "继续";
                            btn_start.Symbol = 61515;
                        }
                        else
                        { 
                            btn_start.Text = "暂停";
                            btn_start.Symbol = 61516;
                        }

                    }
                    break;
                case "btn_claer":
                    {
                        LBX_COM.Items.Clear();
                    }
                    break;
                case "btn_save":
                    {

                    }
                    break;
            }
        }

        private void TIMS_Tick(object sender, EventArgs e)
        {
            if (START == false) return;
            if (opini.ls_com_info.Count > 0)
            {
                LBX_COM.Items.Insert(0, DateTime.Now.ToString(opini.ls_com_info[0]));
                LBX_COM.SelectedIndex = 0;
                if (LBX_COM.Items.Count > 50000) LBX_COM.Items.Clear();
                opini.ls_com_info.RemoveAt(0);
            }
        }
    }
}
